(** Trying to make to become more organized...  These functions are
  * for dimension lists
  *)
let rec map2 f diml1 diml2 = 
  match diml1, diml2 with 
      [],[] -> []
    | d1::diml1',[] -> (f d1 1) :: (map2 f diml1' [])
    | [],d2::diml2' -> (f 1 d2) :: (map2 f [] diml2')
    | d1::diml1',d2::diml2' -> (f d1 d2) :: (map2 f diml1' diml2')

let rec fold_left2 f a diml1 diml2 =
  match diml1, diml2 with
      [],[] -> a
    | d1::diml1',[] -> (f (fold_left2 f a diml1' []) d1 1)
    | [],d2::diml2' -> (f (fold_left2 f a [] diml2') 1 d2)
    | d1::diml1',d2::diml2' -> (f (fold_left2 f a diml1' diml2') d1 d2)

let equal diml1 diml2 =
  fold_left2 (fun a d1 d2 -> a&&(d1==d2)) true diml1 diml2
  
